/* home.css - 首页专属样式 */

/* 鼠标交互背景层 */
#interactive-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: hidden;
}

/* 粒子系统 */
#particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, rgba(76, 175, 80, 0.8) 0%, rgba(76, 175, 80, 0) 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 3s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        transform: translate(0, 0) scale(0);
        opacity: 1;
    }
    50% {
        transform: translate(var(--random-x, 0), var(--random-y, 0)) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translate(var(--random-x, 0), var(--random-y, 0)) scale(0);
        opacity: 0;
    }
}

/* 鼠标光晕效果 */
#mouse-glow {
    position: absolute;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, 
        rgba(76, 175, 80, 0.15) 0%, 
        rgba(76, 175, 80, 0.08) 30%, 
        rgba(76, 175, 80, 0.03) 60%, 
        transparent 100%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease-out;
    mix-blend-mode: screen;
    filter: blur(1px);
}

/* 波纹效果 */
#ripple-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.ripple {
    position: absolute;
    border: 2px solid rgba(76, 175, 80, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: rippleExpand 1s ease-out forwards;
}

@keyframes rippleExpand {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 300px;
        height: 300px;
        opacity: 0;
    }
}

/* 星空背景 */
#starfield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: twinkle 2s ease-in-out infinite alternate;
}

.star.large {
    width: 3px;
    height: 3px;
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

.star.medium {
    width: 2px;
    height: 2px;
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
}

.star.small {
    width: 1px;
    height: 1px;
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
}

@keyframes twinkle {
    0% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* 星星鼠标交互效果 */
.star.mouse-near {
    animation: starGlow 0.5s ease-out forwards;
}

@keyframes starGlow {
    0% {
        opacity: 0.3;
        transform: scale(0.8);
        box-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
    }
    100% {
        opacity: 1;
        transform: scale(1.5);
        box-shadow: 0 0 12px rgba(76, 175, 80, 0.8), 0 0 20px rgba(76, 175, 80, 0.4);
    }
}

/* 粒子轨迹效果 */
.particle-trail {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(76, 175, 80, 0.6);
    border-radius: 50%;
    pointer-events: none;
    animation: trailFade 1s ease-out forwards;
}

@keyframes trailFade {
    0% {
        opacity: 0.8;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* 移动端优化 */
@media screen and (max-width: 768px) {
    /* 减少移动端的粒子效果以提升性能 */
    #mouse-glow {
        width: 200px;
        height: 200px;
        background: radial-gradient(circle, 
            rgba(76, 175, 80, 0.1) 0%, 
            rgba(76, 175, 80, 0.05) 30%, 
            transparent 60%);
    }
    
    .particle {
        width: 3px;
        height: 3px;
    }
    
    .star.large {
        width: 2px;
        height: 2px;
        box-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
    }
    
    .star.medium {
        width: 1.5px;
        height: 1.5px;
        box-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
    }
    
    .star.small {
        width: 1px;
        height: 1px;
        box-shadow: none;
    }
    
    @keyframes rippleExpand {
        0% {
            width: 0;
            height: 0;
            opacity: 1;
        }
        100% {
            width: 200px;
            height: 200px;
            opacity: 0;
        }
    }

    /* 确保代码动画容器不超出屏幕 */
    .code-animation-container {
        width: 100%;
        overflow: hidden;
    }

    .code-line {
        max-width: 90%;
    }
}

@media screen and (max-width: 480px) {
    /* 超小屏幕进一步优化 */
    #mouse-glow {
        width: 150px;
        height: 150px;
    }
    
    .star {
        animation-duration: 3s;
    }
    
    @keyframes rippleExpand {
        0% {
            width: 0;
            height: 0;
            opacity: 1;
        }
        100% {
            width: 150px;
            height: 150px;
            opacity: 0;
        }
    }
}

/* 高性能设备增强效果 */
@media screen and (min-width: 1200px) {
    #mouse-glow {
        width: 400px;
        height: 400px;
        background: radial-gradient(circle, 
            rgba(76, 175, 80, 0.2) 0%, 
            rgba(76, 175, 80, 0.1) 25%, 
            rgba(76, 175, 80, 0.05) 50%, 
            rgba(76, 175, 80, 0.02) 75%, 
            transparent 100%);
    }
    
    .particle {
        width: 5px;
        height: 5px;
    }
    
    @keyframes rippleExpand {
        0% {
            width: 0;
            height: 0;
            opacity: 1;
        }
        100% {
            width: 400px;
            height: 400px;
            opacity: 0;
        }
    }
}

/* 减少动画以适应低性能设备 */
@media (prefers-reduced-motion: reduce) {
    .particle,
    .particle-trail,
    .star,
    .ripple {
        animation: none;
    }
    
    #mouse-glow {
        transition: none;
    }
    
    #interactive-bg {
        display: none;
    }
}

/* 加载动画 */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}

.loader-content {
    text-align: center;
    color: white;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 代码滚动效果 */
.code-animation-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 120px;
    overflow: hidden;
    background: linear-gradient(to bottom, 
        rgba(248, 249, 250, 0) 0%,
        rgba(248, 249, 250, 0.3) 20%,
        rgba(248, 249, 250, 0.7) 50%,
        rgba(248, 249, 250, 1) 100%);
    backdrop-filter: blur(8px);
}

.code-line {
    position: absolute;
    top: -30px;
    white-space: nowrap;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: #f8f9fa;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8), 
                 0 0 8px rgba(76, 175, 80, 0.3);
    padding: 2px 0;
    animation: scrollCodeVertical 20s linear infinite;
    width: auto;
    max-width: 80%;
}

/* 为每行代码设置不同的延迟和位置 */
.code-line:nth-child(1) { 
    animation-delay: 0s; 
    left: 10%;
}
.code-line:nth-child(2) { 
    animation-delay: -1.5s; 
    left: 60%;
}
.code-line:nth-child(3) { 
    animation-delay: -3s; 
    left: 25%;
}
.code-line:nth-child(4) { 
    animation-delay: -4.5s; 
    left: 75%;
}
.code-line:nth-child(5) { 
    animation-delay: -6s; 
    left: 5%;
}
.code-line:nth-child(6) { 
    animation-delay: -7.5s; 
    left: 50%;
}
.code-line:nth-child(7) { 
    animation-delay: -9s; 
    left: 35%;
}
.code-line:nth-child(8) { 
    animation-delay: -10.5s; 
    left: 80%;
}
.code-line:nth-child(9) { 
    animation-delay: -12s; 
    left: 15%;
}
.code-line:nth-child(10) { 
    animation-delay: -13.5s; 
    left: 65%;
}
.code-line:nth-child(11) { 
    animation-delay: -15s; 
    left: 30%;
}
.code-line:nth-child(12) { 
    animation-delay: -16.5s; 
    left: 70%;
}
.code-line:nth-child(13) { 
    animation-delay: -18s; 
    left: 20%;
}
.code-line:nth-child(14) { 
    animation-delay: -19.5s; 
    left: 55%;
}
.code-line:nth-child(15) { 
    animation-delay: -1s; 
    left: 40%;
}
.code-line:nth-child(16) { 
    animation-delay: -2.5s; 
    left: 85%;
}
.code-line:nth-child(17) { 
    animation-delay: -4s; 
    left: 8%;
}
.code-line:nth-child(18) { 
    animation-delay: -5.5s; 
    left: 45%;
}
.code-line:nth-child(19) { 
    animation-delay: -7s; 
    left: 72%;
}
.code-line:nth-child(20) { 
    animation-delay: -8.5s; 
    left: 18%;
}
.code-line:nth-child(21) { 
    animation-delay: -10s; 
    left: 58%;
}

/* C++ 语法高亮样式 */
.code-keyword {
    color: #7eb3f3; /* 增强蓝色 - 关键字 */
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.code-string {
    color: #f4b973; /* 增强橙色 - 字符串 */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.code-identifier {
    color: #b8e6ff; /* 增强浅蓝色 - 标识符 */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.code-class {
    color: #6ee7ca; /* 增强青色 - 类名 */
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.code-type {
    color: #7dd3ff; /* 增强亮蓝色 - 类型 */
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.code-function {
    color: #fff2cc; /* 增强黄色 - 函数名 */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.code-number {
    color: #d4edcc; /* 增强浅绿色 - 数字 */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.code-operator {
    color: #ffffff; /* 纯白色 - 操作符 */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

@keyframes scrollCodeVertical {
    0% {
        transform: translateY(-30px);
        opacity: 0;
    }
    
    5% {
        transform: translateY(-20px);
        opacity: 0;
    }
    
    25% {
        transform: translateY(10px);
        opacity: 1;
    }
    
    75% {
        opacity: 1;
    }
    
    90% {
        opacity: 0.3;
    }
    
    100% {
        transform: translateY(120px);
        opacity: 0;
    }
}

/* 计数器样式 */
/* .counter-container {
    text-align: center;
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: rgba(0, 0, 0, 0.7);
    padding: 15px 25px;
    border-radius: 10px;
    color: white;
    font-family: var(--font-mono);
    text-align: center;
    z-index: 5;
}

.counter-title {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: var(--color-secondary);
}

.counter-time {
    font-size: 1.5rem;
    font-weight: bold;
} */
.counter-container {
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    /* background: white; */
    padding: 15px 25px;
    border-radius: 10px;
    color: rgba(0, 0, 0, 0.5);
    font-family: var(--font-mono);
    text-align: center;
    z-index: 5;
    min-width: 200px;
}

/* .counter-title {
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: var(--color-secondary);
} */

.counter-time {
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 2px;
}

.counter-date {
    font-size: 0.9rem;
    margin-top: 5px;
    opacity: 0.8;
}


/* 增强现有元素 */
.hero {
    position: relative;
    overflow: hidden;
}

.feature-box {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-box:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.testimonial-box {
    position: relative;
    overflow: hidden;
}

.testimonial-box::before {
    content: '"';
    position: absolute;
    top: -20px;
    left: 10px;
    font-size: 100px;
    color: rgba(76, 175, 80, 0.1);
    font-family: var(--font-display);
    line-height: 1;
}

/* 响应式调整 */
/* @media screen and (max-width: 768px) {
    .counter-container {
        bottom: 20px;
        right: 20px;
        padding: 10px 15px;
    }

    .counter-time {
        font-size: 1.2rem;
    }

    .waves-container {
        height: 70px;
    }
} */
@media screen and (max-width: 768px) {
    .counter-container {
        bottom: 50px;
        padding: 10px 15px;
        min-width: 180px;
    }

    .counter-time {
        font-size: 1.5rem;
    }
    
    /* 移动端代码滚动优化 */
    .code-animation-container {
        height: 80px;
    }
    
    .code-line {
        font-size: 11px;
        line-height: 1.4;
        max-width: 70%;
    }
    
    @keyframes scrollCodeVertical {
        0% {
            transform: translateY(-25px);
            opacity: 0;
        }
        
        8% {
            transform: translateY(-15px);
            opacity: 0;
        }
        
        30% {
            transform: translateY(8px);
            opacity: 1;
        }
        
        70% {
            opacity: 1;
        }
        
        88% {
            opacity: 0.3;
        }
        
        100% {
            transform: translateY(80px);
            opacity: 0;
        }
    }
}

@media screen and (max-width: 480px) {
    .code-animation-container {
        height: 60px;
    }
    
    .code-line {
        font-size: 10px;
        line-height: 1.3;
        max-width: 60%;
    }
    
    @keyframes scrollCodeVertical {
        0% {
            transform: translateY(-20px);
            opacity: 0;
        }
        
        10% {
            transform: translateY(-12px);
            opacity: 0;
        }
        
        35% {
            transform: translateY(5px);
            opacity: 1;
        }
        
        65% {
            opacity: 1;
        }
        
        85% {
            opacity: 0.3;
        }
        
        100% {
            transform: translateY(60px);
            opacity: 0;
        }
    }
}